
#include <iostream>
#include <boost\compute.hpp>
#include <boost\compute\device.hpp>
#include <boost\compute\system.hpp>
#include <boost\compute\core.hpp>

#pragma comment(lib, "OpenCL.lib")

namespace compute = boost::compute;


int main()
{
	compute::device dvc = compute::system::default_device();
	std::cout << dvc.name() << "\n";

	// get the default compute device
	compute::device gpu = compute::system::default_device();

	// create a compute context and command queue
	compute::context ctx(gpu);
	compute::command_queue queue(ctx, gpu);

	// generate random numbers on the host
	std::vector<float> host_vector(1000000);
	std::generate(host_vector.begin(), host_vector.end(), rand);

	// create vector on the device
	compute::vector<float> device_vector(1000000, ctx);

	// copy data to the device
	compute::copy(
		host_vector.begin(),
		host_vector.end(),
		device_vector.begin(),
		queue
	);

	// sort data on the device
	compute::sort(
		device_vector.begin(),
		device_vector.end(),
		queue
	);

	// copy data back to the host
	compute::copy(
		device_vector.begin(),
		device_vector.end(),
		host_vector.begin(),
		queue
	);

	std::copy(host_vector.begin(), host_vector.end(), std::ostream_iterator<float>(std::cout, "\n"));

	return 0;
}